<script setup>
import Student from "@/view/Student.vue";
import Dormitory from "@/view/Dormitory.vue";
import Login from "@/view/Login.vue";
import {useCounterStore} from "@/assets/counter-index.js";
const gs = useCounterStore()

//读取本地的 token值
const token = localStorage.getItem("token")
if (token){
  gs.isLogin=true;
  gs.token= token ;
}
const logout = ()=>{
  localStorage.removeItem("token");
  gs.isLogin=false;
}
</script>
//scope象征所有数据，scope.row.id象征目标行的id
<template>
  <div v-if="gs.isLogin">
    <div class="top">
      <span>
        <img src="/logo.png" alt="" style="height: 40px">
      <span style="font-size: 1.25rem;font-weight: 500">好评如潮文件管理系统</span>
      </span>
      <span><el-button plain @click="logout">退出登录</el-button></span>

    </div>
    <div class="content">
      <div class="content-left" style="height: calc(100vh - 70px)">
        <el-menu router default-active="1" style="height: 100%">
          <el-menu-item index="/"><el-icon><Coffee /></el-icon>欢迎页</el-menu-item>
          <el-menu-item index="/student"><el-icon><User /></el-icon>学员管理</el-menu-item>
          <el-menu-item index="/dormitory"><el-icon><School /></el-icon>寝室管理</el-menu-item>
          <el-menu-item index="3"><el-icon><Reading /></el-icon>课程管理</el-menu-item>
          <el-menu-item index="4"><el-icon><House /></el-icon>食堂管理</el-menu-item>
        </el-menu>
      </div>
      <div class="content-right">
<!--        <Student />-->
        <RouterView />
      </div>


    </div>
  </div>
  <div v-if="!gs.isLogin">
    <login/>
  </div>
</template>

<style scoped>
.top{
  height: 50px;
  padding: 5px 20px;
  box-sizing: border-box;
  border-bottom: 1px solid #bfbfbf;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.content{
  width: 100%;
  display: flex;
  justify-content:space-between;
  align-items: flex-start;
}
.content-left{
  width: 130px;
}
.content-right{
  flex-grow: 1;
  padding: 10px 10px;
}
</style>
